<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>学生成绩管理系统 - 管理员</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/all.min.css" rel="stylesheet">
    <style>
        .sidebar {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            z-index: 100;
            padding: 48px 0 0;
            box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
            background-color: #f8f9fa;
        }
        .sidebar-sticky {
            position: relative;
            top: 0;
            height: calc(100vh - 48px);
            padding-top: .5rem;
            overflow-x: hidden;
            overflow-y: auto;
        }
        .navbar {
            box-shadow: 0 2px 4px rgba(0,0,0,.1);
        }
        .main-content {
            margin-left: 240px;
            padding: 20px;
        }
        .nav-link {
            color: #333;
            padding: 10px 20px;
        }
        .nav-link:hover {
            background-color: #e9ecef;
        }
        .nav-link.active {
            background-color: #007bff;
            color: white;
        }
        .nav-link i {
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">学生成绩管理系统</a>
            <div class="d-flex">
                <span class="navbar-text me-3">
                    欢迎，${sessionScope.user.username}
                </span>
                <button class="btn btn-outline-light" onclick="logout()">退出</button>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <nav class="col-md-3 col-lg-2 d-md-block sidebar">
                <div class="sidebar-sticky">
                    <ul class="nav flex-column">
                        <li class="nav-item">
                            <a class="nav-link active" href="index.jsp">
                                <i class="fas fa-home"></i>首页
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="student.jsp">
                                <i class="fas fa-user-graduate"></i>学生管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="teacher.jsp">
                                <i class="fas fa-chalkboard-teacher"></i>教师管理
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>

            <main class="main-content">
                <div class="container">
                    <h2 class="mb-4">系统概览</h2>
                    <div class="row">
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title">学生总数</h5>
                                    <p class="card-text" id="studentCount">加载中...</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title">教师总数</h5>
                                    <p class="card-text" id="teacherCount">加载中...</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.bundle.min.js"></script>
    <script>
        function logout() {
            $.post('${pageContext.request.contextPath}/user/logout', function() {
                window.location.href = '${pageContext.request.contextPath}/login.jsp';
            });
        }

        // 加载统计数据
        $(document).ready(function() {
            // 加载学生总数
            $.get('${pageContext.request.contextPath}/student/list', function(data) {
                $('#studentCount').text(data.length);
            });

            // 加载教师总数
            $.get('${pageContext.request.contextPath}/teacher/list', function(data) {
                $('#teacherCount').text(data.length);
            });
        });
    </script>
</body>
</html> 